<!DOCTYPE html>
<html class="ui-page-login">

	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<link href="/static/mui/css/mui.css" rel="stylesheet" />
		<link href="/static/mui/css/mui.min.css" rel="stylesheet" />
		<style>
			.area {
				margin: 20px auto 0px auto;
			}
			.mui-input-group {
				margin-top: 10px;
			}
			.mui-input-group:first-child {
				margin-top: 20px;
			}
			.mui-input-group label {
				width: 22%;
			}
			.mui-input-row label~input,
			.mui-input-row label~select,
			.mui-input-row label~textarea {
				width: 78%;
			}
			.mui-checkbox input[type=checkbox],
			.mui-radio input[type=radio] {
				top: 6px;
			}
			.mui-content-padded {
				margin-top: 25px;
			}
			.mui-btn {
				padding: 10px;
			}
		</style>

	</head>

	<body>
		<header class="mui-bar mui-bar-nav">
			<h1 class="mui-title">用户登录</h1>
		</header>
		<div class="mui-content">
			<form id='login-form' class="mui-input-group">
				<div class="mui-input-row">
					<label>账号</label>
					<input id='account' type="text" class="mui-input-clear mui-input" placeholder="请输入账号">
				</div>
				<div class="mui-input-row">
					<label>密码</label>
					<input id='password' type="password" class="mui-input-clear mui-input" placeholder="请输入密码">
				</div>
			</form>
			<div class="mui-content-padded">
				<button id='login' class="mui-btn mui-btn-block mui-btn-primary" type="button" onclick="return login();">登录</button>
			</div>
		</div>
		<script src="/static/mui/js/mui.js"></script>
		<script src="/static/mui/js/mui.min.js"></script>
	</body>

</html>

<script type="text/javascript">

mui.init({
	statusBarBackground: '#f7f7f7'
});

function login(account, password, group) {
	mui.toast('正在登录，请稍后...',{ duration:'long', type:'div' })
	mui.ajax(app.getDomain() + "/admin/mob/login", {
		data: {
			loginName: account,
			loginPwd: app.md5(password),
			loginGroup: group
		},
		type: "post",
		dataType: 'json',
		timeout: 5000,
		error: function(request) {
			mui.toast("登录失败！",{ duration:'long', type:'div' });
			wait.close();
		},
		success: function(user) {
			if (user.id == 0) {
				wait.close();
				mui.toast(user.msg,{ duration:'long', type:'div' });
			} else {
				settings.user = user;
				settings.password =password;
				//console.log(JSON.stringify(settings));
				app.setSettings(settings);
				wait.close();
				setTimeout(function() {
					mui.openWindow({
						id: 'main',
						url: '../admin/main.html'
					});
				}, 100);

			}
		}
	});
}

</script>
